load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")
load("//prow:def.bzl", "prow_image", "prow_push")

NAME = "resultstore"

prow_image(
    name = "image",
    component = NAME,
)

prow_push(
    name = "push",
    images = {
        "{STABLE_DOCKER_REPO}/resultstore:{DOCKER_TAG}": ":image",
        "{STABLE_DOCKER_REPO}/resultstore:latest": ":image",
        "{STABLE_DOCKER_REPO}/resultstore:latest-{BUILD_USER}": ":image",
    },
)

go_library(
    name = "go_default_library",
    srcs = [
        "convert.go",
        "download.go",
        "main.go",
        "upload.go",
    ],
    importpath = "k8s.io/test-infra/experiment/resultstore",
    visibility = ["//visibility:private"],
    deps = [
        "//prow/apis/prowjobs/v1:go_default_library",
        "//prow/flagutil:go_default_library",
        "//prow/logrusutil:go_default_library",
        "@com_github_googlecloudplatform_testgrid//config:go_default_library",
        "@com_github_googlecloudplatform_testgrid//metadata:go_default_library",
        "@com_github_googlecloudplatform_testgrid//pb/config:go_default_library",
        "@com_github_googlecloudplatform_testgrid//resultstore:go_default_library",
        "@com_github_googlecloudplatform_testgrid//util/gcs:go_default_library",
        "@com_github_sirupsen_logrus//:go_default_library",
        "@com_google_cloud_go_storage//:go_default_library",
        "@io_k8s_sigs_yaml//:go_default_library",
    ],
)

go_binary(
    name = NAME,
    embed = [":go_default_library"],
    visibility = ["//visibility:public"],
)

filegroup(
    name = "package-srcs",
    srcs = glob(["**"]),
    tags = ["automanaged"],
    visibility = ["//visibility:private"],
)

filegroup(
    name = "all-srcs",
    srcs = [":package-srcs"],
    tags = ["automanaged"],
    visibility = ["//visibility:public"],
)

go_test(
    name = "go_default_test",
    srcs = [
        "convert_test.go",
        "main_test.go",
    ],
    embed = [":go_default_library"],
    deps = [
        "@com_github_google_go_cmp//cmp:go_default_library",
        "@com_github_googlecloudplatform_testgrid//metadata:go_default_library",
        "@com_github_googlecloudplatform_testgrid//metadata/junit:go_default_library",
        "@com_github_googlecloudplatform_testgrid//pb/config:go_default_library",
        "@com_github_googlecloudplatform_testgrid//resultstore:go_default_library",
        "@com_github_googlecloudplatform_testgrid//util/gcs:go_default_library",
        "@io_k8s_apimachinery//pkg/api/equality:go_default_library",
        "@io_k8s_apimachinery//pkg/util/diff:go_default_library",
    ],
)
